package com.baibei.ebec.welfare.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.baibei.basic.BasicRecyclerViewAdapter;
import com.baibei.ebec.home.R;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.Map;

/**
 * Created by tang on 2018/4/13.
 */

public class MyUserAdapter extends RecyclerView.Adapter<MyUserAdapter.ViewHolder> {

    private ArrayList<Map<String,String>> datas;
    public MyUserAdapter(ArrayList<Map<String,String>> datas){
        this.datas = datas;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_myuser_welfare, null);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, int i) {
        viewHolder.tvUserName.setText(datas.get(i).get("userName"));
        viewHolder.tvRegistTime.setText(datas.get(i).get("registTime"));
        viewHolder.tvPaidFee.setText(datas.get(i).get("paidFee"));
        viewHolder.tvTradeNum.setText(datas.get(i).get("tradeNum"));
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView tvUserName;
        private final TextView tvRegistTime;
        private final TextView tvPaidFee;
        private final TextView tvTradeNum;

        public ViewHolder(View itemView) {
            super(itemView);
            tvUserName = itemView.findViewById(R.id.tv_username);
            tvRegistTime = itemView.findViewById(R.id.tv_regist_time);
            tvPaidFee = itemView.findViewById(R.id.tv_paid_fee);
            tvTradeNum = itemView.findViewById(R.id.tv_trade_num);
        }
    }
}
